import 'dart:math' as math;
import 'dart:async';
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';

void main() => runApp(const SearchIndexCopy());

/// This is the main application widget.
class SearchIndexCopy extends StatelessWidget {
  const SearchIndexCopy({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: "Flutter",
      home: MyStatefulWidget(),
    );
  }
}

/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

/// This is the private State class that goes with MyStatefulWidget.
/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin.
class _MyStatefulWidgetState extends State<MyStatefulWidget>
    with TickerProviderStateMixin {
  late final AnimationController _controller = AnimationController(
    duration: const Duration(seconds: 10),
    vsync: this,
  )..repeat();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    double widthSize = MediaQuery.of(context).size.width as double; // 360.0
    double heightSize = MediaQuery.of(context).size.height as double; // 640.0
    print(widthSize.toString());
    print(heightSize.toString());
    return ListView(
      children: [
        Stack(
          children: [
            Container(
              width: 60,
              height: 60,
              color: Colors.deepPurpleAccent,
            ),
            Positioned(
              top: 0,
              left: 1,
              child: AnimatedBuilder(
                animation: _controller,
                child: Padding(
                  child: Container(
                      width: 50.0,
                      height: 50.0,
                      //alignment: Alignment.center,
                      child: Padding(
                        padding: EdgeInsets.all(2),
                        child: Container(
                          width: 27,
                          height: 27,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                            border:
                                Border.all(width: 10, color: Colors.black26),
                            borderRadius: BorderRadius.circular(200),
                            color: Color.fromRGBO(60, 63, 65, 1),
                            // image: DecorationImage(
                            //     image: NetworkImage(
                            //         "http://rec6p45ah.hn-bkt.clouddn.com/666.jpg"),
                            //     fit: BoxFit.fill),
                          ),
                          child: Container(
                            decoration: BoxDecoration(
                              border:
                                  Border.all(width: 10, color: Colors.black26),
                              borderRadius: BorderRadius.circular(30),
                              //color: Colors.orange,
                              image: DecorationImage(
                                  image: NetworkImage(
                                      "http://rec6p45ah.hn-bkt.clouddn.com/666.jpg"),
                                  fit: BoxFit.fill),
                            ),
                          ),
                        ),
                      )),
                  padding:
                      EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
                ),
                builder: (BuildContext context, Widget? child) {
                  return Transform.rotate(
                    angle: _controller.value * 2.0 * math.pi,
                    child: child,
                  );
                },
              ),
            ),
          ],
        ),
        Container(
          width: 200,
          height: 200,
          color: Colors.orange,
          child: Container(
            width: 100,
            height: 100,
            color: Colors.blueAccent,
            child: ListView(
              children: [
                Icon(
                  IconData(0xe7f6, fontFamily: 'MyIcons'),
                  color: Colors.white,
                  size: 30,
                ),
                Icon(
                  IconData(0xe78e, fontFamily: 'MyIcons'),
                  color: Colors.white,
                  size: 25,
                )
              ],
            ),
          ),
        ),
        Padding(
          padding: EdgeInsets.only(left: 1, right: 140),
          child: BrnNoticeBar(
            content: '这是跑马灯的通知内容跑马灯',
            marquee: true,
            textColor: Colors.white,
            backgroundColor: Color.fromRGBO(222, 222, 222, 0),
            showRightIcon: false,
            showLeftIcon: false,
            noticeStyle: NoticeStyles.runningWithArrow,
            onNoticeTap: () {
              //BrnToast.show('点击通知', context);
            },
            onRightIconTap: () {
              //BrnToast.show('点击右侧图标', context);
            },
          ),
        ),
      ],
    );
  }
}
